package com.pty.demo.behaviour.strategy;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author pengty
 * @date 2020/3/13
 */
public class StrategyFactory {

    private static Map<String, CookingCarpStrategy> strategyMap = Maps.newConcurrentMap();

    static {
        strategyMap.put("braised", new BraisedCarpStrategy());
        strategyMap.put("soup", new SoupCarpStrategy());
    }

    public void putStrategy(String key, CookingCarpStrategy strategy) {
        strategyMap.put(key, strategy);
    }

    public CookingCarpStrategy getStrategy(String key) {
        System.out.println("通过策略工厂获得策略 ： " + key);
        return strategyMap.get(key);
    }

}
